using System;
using System.Collections.Generic;
using System.Text;
using Lizk.SimpleHUD;

namespace SharpMedia.Controls
{
    public class HUDVertBar : HUDContainerSimple
    {
        HUDImage progressBar;
        
        public HUDVertBar()
        {
            Size = new SizeS(27, 4);

            HUDImage side = new HUDImage("white.png");
            side.Bounds = new RectangleS(0, 0, Size.Width, 1);
            side.Anchor = Anchor.All ^ Anchor.Bottom;
            side.ConstrainProportions = false;
            Add(side);

            side = new HUDImage("white.png");
            side.Bounds = new RectangleS(0, Size.Height - 1, Size.Width, 1);
            side.ConstrainProportions = false;
            side.Anchor = Anchor.All ^ Anchor.Top;
            Add(side);

            side = new HUDImage("white.png");
            side.ConstrainProportions = false;
            side.Bounds = new RectangleS(0, 1, 1, Size.Height - 2);
            side.Anchor = Anchor.All ^ Anchor.Right;
            Add(side);

            side = new HUDImage("white.png");
            side.Bounds = new RectangleS(Size.Width - 1, 1, 1, Size.Height - 2);
            side.ConstrainProportions = false;
            side.Anchor = Anchor.All ^ Anchor.Left;
            Add(side);

            progressBar = new HUDImage("progress_vg.png");
            progressBar.Bounds = new RectangleS(2, Size.Height - 2 - 1, 23, 1);
            progressBar.ConstrainProportions = false;
            Add(progressBar);
        }

        private float maxValue = 100;

        public float MaxValue
        {
            get { return maxValue; }
            set { maxValue = value; }
        }

        private float minValue = 0;

        public float MinValue
        {
            get { return minValue; }
            set { minValue = value; }
        }
        
        private float value = 0;

        public float Value
        {
            get { return value; }
            set { this.value = value; }
        }


        public override void Update(TimeSpan ts)
        {
            float height = ((value - minValue) / (maxValue - minValue)) * (Size.Height - 4);
            progressBar.Bounds = new RectangleS(2, Size.Height - 2 - height, 23, height);
            base.Update(ts);
        }

    }
}
